const obj = {
  name: 100
}
let count = 0

Object.defineProperty(obj, 'name', {
  get: function () {
    count++
    return ++count
  },
  set: function (newValue) {
    count += newValue
    return console.log('设置数据成功')
  }
})

console.log(obj.name) // 2
obj.name = 100;  // 102
console.log(obj.name) // 104    输出时再次走了一次 get 



